<?php

// 公共助手函数

use app\common\library\Auth;
use think\Cache;



/**
 * 获取中英文数据
 * @param $model_name  模型名称
 * @param $name 字段名称
 * @param string $stu 语言字段
 * @param string $m 模块
 * @return mixed|string
 * @throws \think\db\exception\DataNotFoundException
 * @throws \think\db\exception\ModelNotFoundException
 * @throws \think\exception\DbException
 */
if (!function_exists('__api')) {
    function __api($model_name, $name, $m = 'official')
    {
        //获取语言
        $language = (int)input('param.uni_language');
        //判断语言
        $language = ($language == 1) ? 'en' : 'zh-cn';
        //获取语言包地址
        $url = ROOT_PATH . "addons/$m/lang/api/$language/official_$model_name.php";
        if (file_exists($url)) {
            $data = include $url;
            if (isset($data[$name]) && !empty($data[$name])) {
                return $data[$name];
            }
        }
        //如果没有模型
        $common = ROOT_PATH . "addons/$m/lang/api/$language.php";
        if (file_exists($common)) {
            $common_f = include $common;
            if (isset($common_f[$name]) && !empty($common_f[$name])) {
                return $common_f[$name];
            }
        }
        return $name;
    }
}



